#define _CRT_SECURE_NO_WARNINGS 1
#include <atomic>
#include <iostream>
using namespace std;

int main() {
    int a, h, b, k;
    cin >> a >> h >> b >> k;
    int atime = h / b;
    int btime = k / a;
    int sum = 0;
    if (atime > btime)
    {
        h -= btime * b;
        k -= btime * a;
        sum += a * btime;
        sum += b * btime;
    }
    else {
        h -= atime * b;
        k -= atime * a;
        sum += a * atime;
        sum += b * atime;
    }
    if (h - b <= 0 && k - a <= 0)
    {
        cout << sum;
    }
    else if (h - b <= 0)
    {
        cout << sum + b * 10;
    }
    else {
        cout << sum + a * 10;
    }
    return 0;
}